package com.aliware.edas;

import com.aliware.edas.bean.User;
import com.aliware.edas.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author edas
 */
@RefreshScope
@RestController
public class EchoController {

    @Value("${test.name}")
    private String userName;

    @Autowired
    UserMapper userMapper;
    @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
    public String echo(@PathVariable String string) {
        return string;
    }

    @RequestMapping(value = "/getUserName")
    public String getUserName() {
        return userName;
    }

    @RequestMapping(value = "/getUserInfo",method = RequestMethod.GET)
    public User getUserInfo(int id) {
        User user = userMapper.selectById(id);
        return user;
    }
}